<template>
	<view class="login">
		<view class="title">
			<text>核验登录</text>
			<text>请使用核验工作人员账号登录</text>
		</view>
		
		<view class="form">
			<view class="li">
				<text>账号</text>
				<input v-model="formData.username" type="text" placeholder="请输入登陆账号" />
			</view>
			<view class="li">
				<text>密码</text>
				<input v-model="formData.password" type="password" placeholder="请输入密码" />
			</view>
		</view>
		
		
		<view class="btn">
			<button @click="onSubmit">立即登陆</button>
		</view>
	</view>
</template>

<script>
	
import request from "@/utils/request.js";	
	export default {
		data() {
			return {
				formData: {
					username: '',
					password: ''
				},
				baseUrl: this.$baseUrl
			}
		},
		methods: {
			onSubmit() {
				if (!this.formData.username) {
					this.$util.Tips({
						title: '请输入账号'
					});
					return false;
				}
				if (!this.formData.password) {
					this.$util.Tips({
						title: '请输入密码'
					});
					return false;
				}
				uni.request({
					url: this.baseUrl + '/api/staff/login',
					method: 'POST',
					header: {},
					data: this.formData,
					success: (res) => {
						console.log('res',res);
						if (res.data.status == 200) {
							uni.setStorageSync('stafftoken', res.data.data.token);
							return this.$util.Tips({
								title: res.data.msg,
								icon: 'success'
							}, {
								tab: 2,
								url: '/pages/staff/index'
							});
						} else {
							this.$util.Tips({
								title: res.data.msg,
								icon: 'error'
							});
						}
						
					}
				})
			}
		}
	}
</script>
<style>
	page {
		background: #fff;
	}
</style>
<style scoped lang="scss">
	.title {
		padding: 30rpx;
		margin: 66rpx 0;
		display: flex;
		flex-direction: column;
		text {
			&:nth-child(1) {
				font-weight: 400;
				font-size: 44rpx;
				color: #222229;
			}
			&:nth-child(2) {
				font-size: 24rpx;
				color: #888889;
				margin-top: 8rpx;
			}
		}
	}
	
	.form {
		padding: 30rpx;
		.li {
			height: 112rpx;
			display: flex;
			align-items: center;
			border-bottom: 2rpx solid #E6E6E8;
			font-size: 32rpx;
			color: #222229;
			text {
				flex: 0 0 70rpx;
			}
			input {
				width: 100%;
				height: 100rpx;
				font-size: 32rpx;
				margin-left: 10rpx;
				margin-top: 3rpx;
			}
		}
	}
	
	.btn {
		margin-top: 100rpx;
		button {
			width: 686rpx;
			height: 88rpx;
			background: #003153;
			border-radius: 8rpx 8rpx 8rpx 8rpx;
			font-size: 32rpx;
			color: #FFFFFF;
			line-height: 88rpx;
			text-align: center;
			margin: 0 auto;
		}
	}
</style>